<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改房间')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-room-edit" th:object="${room}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">房间编号：</label>
                    <div class="col-sm-8">
                        <input name="number" th:field="*{number}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">房间类型：</label>
                    <div class="col-sm-8">
                        <select name="type" class="form-control" th:with="type=${@dict.getType('room_type')}" required>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">房间价格：</label>
                    <div class="col-sm-8">
                        <input name="price" th:field="*{price}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">图片：</label>
                    <!--                 onclick="$.triggerFileInput()"-->
                    <div class="UploadImg">  <!-- 为整个区域添加点击事件 -->
                        <div class="imgList" id="imgList">
                            <!-- 这里用于显示已上传的图片或加载状态 -->
                            <img th:if="${room.imgUrl}" th:src="${room.imgUrl}" width="100" height="100" border-radius="10" border="1px solid #d9d9d9" />
                        </div>
                    </div>
                    <input type="file" id="fileInput" style="display: none;"/>
                    <!-- 隐藏的文件输入元素，并绑定 onchange 事件 -->
                    <input name="imgUrl" id="imgUrl" th:field="*{imgUrl}" class="form-control" type="hidden">
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">房间状态：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('room_status')}">
                            <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}" required>
                            <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/room";
        var uploadUrl = ctx + "common/upload";
        $(document).ready(function() {
            $("#form-product-edit").validate({
                focusCleanup: true
            });

            // 当页面加载完成时，执行以下代码
            $.fileUpload.init();
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-room-edit').serialize());
            }
        }

        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='updatedTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>